<?php
namespace Home\Controller;

use Think\Controller;

class IndexController extends Controller
{
    public function index()
    {
        $code = I('get.code');
        if(!empty($code)){
            session('wxcode',$code);
        }
        $member_id = session('member_id');
        $this->assign('shop_id',$member_id);
        $this->assign('code',$code);
        $url = "http://www.honeybee2015.com/App/Index/Index/wxlogin";
        $url = urlencode($url);
        if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false ) {
            if(empty($member_id)  && empty($code)){
                header("location:http://open.weixin.qq.com/connect/oauth2/authorize?appid=wx09632c5caa1f84d8&redirect_uri=$url&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect");
            }
        }

        $this->display();
    }
}